package com.hengxinguotong.hxgtwygsp.ui.supervise.warning.manager;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.constraint.Group;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.ManagerDeduct;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.OnClick;

public class WarningManagerFragment extends BaseFragment implements WarningManagerContract.IView
{
    @Inject
    WarningManagerContract.IPresenter mPresenter;
    @BindView(R.id.warning_manager_name)
    TextView warningManagerName;
    @BindView(R.id.warning_good_group)
    Group warningGoodGroup;
    @BindView(R.id.warning_local_score)
    TextView warningLocalScore;
    @BindView(R.id.warning_local_card)
    ImageView warningLocalCard;
    @BindView(R.id.warning_local_card_name)
    TextView warningLocalCardName;
    @BindView(R.id.warning_deduct_group)
    Group warningDeductGroup;
    @BindView(R.id.warning_all_score)
    TextView warningAllScore;
    @BindView(R.id.warning_card)
    TextView warningCard;
    @BindView(R.id.warning_all_region)
    TextView warningAllRegion;
    @BindView(R.id.warning_recycler)
    RecyclerView warningRecycler;

    private List<ManagerDeduct> managerDeductList = new ArrayList<>();
    private WarningManagerAdapter managerDeductAdapter;

    public WarningManagerFragment()
    {
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        mPresenter.bindView(this);
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
        mPresenter.dropView();
    }

    @Override
    public int getLayoutResId()
    {
        return R.layout.fragment_warning_manager;
    }

    @Override
    public void init()
    {
        mockView();
        warningRecycler.setNestedScrollingEnabled(false);
        warningRecycler.setFocusableInTouchMode(false);
        LinearLayoutManager llm = new LinearLayoutManager(getContext());
        llm.setOrientation(LinearLayoutManager.VERTICAL);
        warningRecycler.setLayoutManager(llm);
        managerDeductAdapter = new WarningManagerAdapter(R.layout.item_manager_deduct,managerDeductList);
        warningRecycler.setAdapter(managerDeductAdapter);
    }

    private void mockView() {

        managerDeductList.add(new ManagerDeduct("1. 兰方文", "30", "东湖名居"));
        managerDeductList.add(new ManagerDeduct("2. 周华", "25", "紫晶城小区"));
        managerDeductList.add(new ManagerDeduct("3. 吴海明", "25", "九坤翰林苑小区"));
        managerDeductList.add(new ManagerDeduct("4 李成文  ", "25", "鹏湖湾一期"));
    }

    @OnClick({R.id.warning_all_score, R.id.warning_card, R.id.warning_all_region})
    public void onViewClicked(View view)
    {
        switch (view.getId())
        {
            case R.id.warning_all_score:
                break;
            case R.id.warning_card:
                break;
            case R.id.warning_all_region:
                break;
        }
    }


}
